package cn.tqfeiyang.springplus.generator.type;

/**
 * 表字段类型
 */
public class DbColumnType {
    // 基本类型
    public final static DbColumnType BASE_BYTE = new DbColumnType("byte", null);
    public final static DbColumnType BASE_SHORT = new DbColumnType("short", null);
    public final static DbColumnType BASE_CHAR = new DbColumnType("char", null);
    public final static DbColumnType BASE_INT = new DbColumnType("int", null);
    public final static DbColumnType BASE_LONG = new DbColumnType("long", null);
    public final static DbColumnType BASE_FLOAT = new DbColumnType("float", null);
    public final static DbColumnType BASE_DOUBLE = new DbColumnType("double", null);
    public final static DbColumnType BASE_BOOLEAN = new DbColumnType("boolean", null);

    // 包装类型
    public final static DbColumnType BYTE = new DbColumnType("Byte", null);
    public final static DbColumnType SHORT = new DbColumnType("Short", null);
    public final static DbColumnType CHARACTER = new DbColumnType("Character", null);
    public final static DbColumnType INTEGER = new DbColumnType("Integer", null);
    public final static DbColumnType LONG = new DbColumnType("Long", null);
    public final static DbColumnType FLOAT = new DbColumnType("Float", null);
    public final static DbColumnType DOUBLE = new DbColumnType("Double", null);
    public final static DbColumnType BOOLEAN = new DbColumnType("Boolean", null);
    public final static DbColumnType STRING = new DbColumnType("String", null);

    // sql 包下数据类型
    public final static DbColumnType DATE_SQL = new DbColumnType("Date", "java.sql.Date");
    public final static DbColumnType TIME = new DbColumnType("Time", "java.sql.Time");
    public final static DbColumnType TIMESTAMP = new DbColumnType("Timestamp", "java.sql.Timestamp");
    public final static DbColumnType BLOB = new DbColumnType("Blob", "java.sql.Blob");
    public final static DbColumnType CLOB = new DbColumnType("Clob", "java.sql.Clob");

    // java8 新时间类型
    public final static DbColumnType LOCAL_DATE = new DbColumnType("LocalDate", "java.time.LocalDate");
    public final static DbColumnType LOCAL_TIME = new DbColumnType("LocalTime", "java.time.LocalTime");
    public final static DbColumnType YEAR = new DbColumnType("Year", "java.time.Year");
    public final static DbColumnType YEAR_MONTH = new DbColumnType("YearMonth", "java.time.YearMonth");
    public final static DbColumnType LOCAL_DATE_TIME = new DbColumnType("LocalDateTime", "java.time.LocalDateTime");
    public final static DbColumnType INSTANT = new DbColumnType("Instant", "java.time.Instant");

    // 其他杂类
    public final static DbColumnType MAP = new DbColumnType("Map", "java.util.Map");
    public final static DbColumnType BYTE_ARRAY = new DbColumnType("byte[]", null);
    public final static DbColumnType OBJECT = new DbColumnType("Object", null);
    public final static DbColumnType DATE = new DbColumnType("Date", "java.util.Date");
    public final static DbColumnType BIG_INTEGER = new DbColumnType("BigInteger", "java.math.BigInteger");
    public final static DbColumnType BIG_DECIMAL = new DbColumnType("BigDecimal", "java.math.BigDecimal");

    /**
     * 类型
     */
    private final String type;

    /**
     * 包路径
     */
    private final String pkg;

    /**
     * 是否是枚举类型？
     */
    private final boolean enumFlag;

    public DbColumnType(final String type, final String pkg) {
        this.type = type;
        this.pkg = pkg;
        this.enumFlag = false;
    }

    public DbColumnType(final String type, final String pkg, boolean enumFlag) {
        this.type = type;
        this.pkg = pkg;
        this.enumFlag = enumFlag;
    }

    public String getType() {
        return type;
    }

    public String getPkg() {
        return pkg;
    }

    public boolean isEnumClass() {
        return enumFlag;
    }
}